{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#\n",
    "import tensorflow as tf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "# direct sum with constand value\n",
    "a = tf.constant(2)\n",
    "b = tf.constant(3)\n",
    "c=a+b\n",
    "d=a*b\n",
    "\n",
    "sess=tf.Session()\n",
    "print sess.run(c)\n",
    "print sess.run(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "# \n",
    "a = tf.placeholder(tf.int16)\n",
    "b = tf.placeholder(tf.int16)\n",
    "\n",
    "# \n",
    "add = tf.add(a, b)\n",
    "mul = tf.multiply(a, b)\n",
    "print sess.run(add, feed_dict={a: 2, b: 3})\n",
    "print sess.run(mul, feed_dict={a: 2, b: 3})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 6.  6.]\n",
      " [ 6.  6.]]\n"
     ]
    }
   ],
   "source": [
    "#\n",
    "matrix1 = tf.constant([[3., 3.]])\n",
    "matrix2 = tf.constant([[2.],[2.]])\n",
    "product = tf.matmul(matrix2, matrix1)\n",
    "print sess.run(product)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  6.   8.  10.]\n",
      " [  7.   6.   5.]\n",
      " [  5.  10.  15.]]\n"
     ]
    }
   ],
   "source": [
    "mat1=tf.Variable(tf.random_normal([3,2]))\n",
    "mat2=tf.Variable(tf.random_normal([2,3]))\n",
    "product=tf.matmul(mat1,mat2)\n",
    "\n",
    "m1=[[1,3],[2,1],[0,5]]\n",
    "m2=[[3,2,1],[1,2,3]]\n",
    "\n",
    "print sess.run(product,feed_dict={mat1:m1,mat2:m2})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
